
using UnityEngine;

public class PlayerState_Fall : PlayerState
{
    [SerializeField]float airMoveSpeed = 4f;
    [SerializeField]float airRunSpeed = 8f;
    private float currentAirSpeed; 
    private float lastInputJumpTime;
    public override void Enter()
    {
        lastInputJumpTime = -1f;
        currentAirSpeed = input.IsInputRun ? airRunSpeed : airMoveSpeed;
    }
    public override void LogicalUpdate()
    {
        if(input.IsInputJump)
            lastInputJumpTime = Time.time;
        if(motor.isOnGround)
        {
            if(Time.time - lastInputJumpTime < 0.2f)
                manager.SwitchState(typeof(PlayerState_Jump));
            else 
                manager.SwitchState(typeof(PlayerState_Move));
        }
    }
    public override void PhysicalUpdate()
    {
        motor.SetMoveVelocity(input.MoveValue * currentAirSpeed );
        motor.UseGravity();
    }
}
